package com.example.practice.adapter;

import java.util.List;

import org.achartengine.GraphicalView;

import com.example.practice.bean.ChartPagerBean;
import com.example.practice.util.Chart;

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class ChartAdapter extends PagerAdapter {
	private List<ChartPagerBean> beans;
	public ChartAdapter( List<ChartPagerBean> beans) {
		this.beans = beans;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return beans.size();
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		// TODO Auto-generated method stub
		return arg0 == arg1;
	}
	
	
	
	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		// TODO Auto-generated method stub
		  container.removeView((View)object);  
	}

	@Override
	public Object instantiateItem(View container, int position) {
		//填写以下代码
		GraphicalView graphicalView = new Chart().chart(container.getContext(), beans.get(position), null);
		((ViewGroup)container).addView(graphicalView,0);
		return graphicalView;
	}
	


}
